﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit;
using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;

namespace Huirui.Cavan.UnitTest
{
    public class TestSystemModuleRepository
    {
        private IApplicationContext context;

        [SetUp]
        public void SetUp()
        {
            context = ContextRegistry.GetContext();
        }

        [Test]
        public void TestAddAccount()
        {
            IAccountRepository accountRepository = context.GetObject("AccountRepository") as IAccountRepository;
            Account account = null;// SystemModuleFactory.CreateAccount("01","test_account", SystemIdentifier.AccountType.Cash, SystemIdentifier.AccountStatus.Using, 0, null);
            account.Id = "a1";
            accountRepository.Save(account);

            Assert.IsNotNull(account);
        }

        [Test]
        public void TestGetRole()
        {
            IRoleRepository roleRepository = context.GetObject("RoleRepository") as IRoleRepository;
            Role role = roleRepository.Get(1);

            Assert.IsNotNull(role);
        }

        [Test]
        public void TestGetUserAccount()
        {
            IUserAccountRepository userAccountRepository = context.GetObject("UserAccountRepository") as IUserAccountRepository;
            UserAccount userAccount = userAccountRepository.Get(1);

            Assert.IsNotNull(userAccount);
        }
    }
}
